
/* -----------------
* brief 
* 1. this is code gen by tools 
* 2. array like [a,b,c] after each field, define the ui html tag in view, 
		a for title, 
		b for show or not , (onlyread is trial feature)
		c for element html tag , currently support : check、radio、select、input、textarea、upload
* 3. XXX
*/
//使用方法：在工程root目录下，执行go generate ./modules/appmanager/models
//go:generate legogen -type=AppAttr -kv=ModuleName=appmanager,PrjName=saas_sys_base -dirconf=../../.. ./AppAttr.go
package appmanager

import (
	"github.com/mjiulee/lego"
	"saas_sys_base/common"
)

func init() {
	lego.AddBeanToSynList(new(AppAttr))
}

/* table: "tb_app_attr"
 * -----------------
*/
type AppAttr struct {
	Id        int64  `xorm:"pk" json:",string"`                  // ["id","hide","hidden"]
	IfDel     int `xorm:"default 0"` // ["deleted","hide","hidden"]
	Cdate     string `xorm:"DateTime created"`    // ["create","show","datetime"]
	Udate     string `xorm:"DateTime updated"`    // ["update","show","datetime"]
    // add your custom field here
	MiniAppId int64 `xorm:"unique" json:",string"` // ["MiniAppId","show","input"]
	//Uid int64 `xorm:""` // ["Uid","show","input"]

	MiniAppName     string `xorm:"char(64) default 'N'"` // ["APP名字","hide","input"]
	MiniAppBrief  string `xorm:"char(64) default 'N'"` // ["简介/说明","show","textarea"]

	//RunState: 运行状态：0-未运行， 1-正在运行，
	RunState int `xorm:"int default 0"` // ["激活状态","show","tag"]

	//RunState: 运行状态：0-未激活， 1-已激活，使用STATE_YES和STATE_NO宏
	ActiveState int `xorm:"int default 0"` // ["激活状态","show","input"]

	Logo     string `xorm:"text"` // ["LOGO","show","upload"]
	Version     string `xorm:"char(32) default 'N'"` // ["版本","show","tag"]
	Order int `xorm:"int default 0"` // ["排序","show","input"]
}

func NewAppAttrByAppConfig(config *common.AppConfig) *AppAttr{
	if config == nil {
		return nil
	}

	attr := &AppAttr{
		MiniAppId:config.Who.Mini_App_Id,
		MiniAppName: config.APPName,
		MiniAppBrief: config.AppBrief,
		Version:config.AppVersion,

	}
	return attr
}